let gd = require("../servies/data.js")
module.exports = {
    router:async ctx => {
        await  ctx.render("index.html")
    },
    getdata:async ctx => {
     let page =   ctx.originalUrl.split("=")[1];
    //  console.log(page);
     if(page){
        let data = await gd.getpage(page);
        ctx.body = data;
     }else{
        let data = await gd.getdata();
        // console.log(data);
        ctx.body = data;
     } 
    },
    detailView: async ctx => {
        await ctx.render("index2.html");
    },
    detailData: async ctx => {
        let id = ctx.req.url.split("=")[1];
        ctx.body = await gd.getdata(id);
    },
}
